home *** CD-ROM | disk | FTP | other *** search
/ Aminet 43 / Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso / Aminet / comm / tcp / Amster-main.lha / Amster_Install / Rexx / AmsterReport_Triton.rexx < prev    next >
OS/2 REXX Batch file  |  2000-09-08  |  8KB  |  261 lines

  1. /*
  2. ** Scans the Amster.shares file and gives a report on the statistics of your library.
  3. ** $VER: AmsterReport.rexx 0.3 (08.9.2000)
  4. **
  5. ** By Roger Clark (kaedric@texas.net)
  6. ** September 8, 2000
  7. **
  8. ** This script requires the rexxreqtools.library which can be found on Aminet.
  9. **
  10. **                      util/rexx/RexxReqTools.lha
  11. **
  12. ** This script requires the tritonrexx.library which can be found on Aminet.
  13. **                      util/rexx/TritonRexx376.lha
  14. **
  15. ** This script requires the triton.library which can be found on Aminet.
  16. **                      dev/gui/tri20b1usr.lha
  17. **
  18. */
  19.  
  20. Options Results
  21. Parse Arg ShareList
  22.  
  23. Signal On Break_C
  24. Signal On failure
  25. Signal On halt
  26. Signal On ioerr
  27. Signal On syntax
  28.  
  29. If ~Show('L','tritonrexx.library') Then Do
  30.    If ~addlib('tritonrexx.library',10,-30,0) Then Do
  31.       Say 'Could not access the tritonrexx.library!'
  32.       Exit 10
  33.    End
  34. End
  35.  
  36. If ~Show('L','rexxreqtools.library') Then Do
  37.    If ~addlib('rexxreqtools.library',10,-30,0) Then Do
  38.       Say 'Could not access the rexxreqtools.library!'
  39.       Exit 10
  40.    End
  41. End
  42.  
  43. NumSongs = 0
  44. NumBytes = 0
  45. NumBytesSent = 0
  46. SBytes = 0
  47. UBytes = 0
  48. NumReq = 0
  49. NumSecs = 0
  50. TopSongs. = ""
  51. TopSongs.0 = 0
  52. TopReq = 0
  53. SFlag = "KB"
  54. UFlag = "KB"
  55. Playtime = "0:00:00"
  56. Dir = ""
  57. DefaultFile = "Amster.shares"
  58.  
  59. windowtags =    WindowID(1),
  60.                 WindowTitle('Amster Report'),
  61.                   BeginMenu('Project'),
  62.                     MenuItem('N_New Report',7),
  63.                     MenuItem('?_About',8),
  64.                     MenuItem('Q_Quit',9),
  65.                   'HorizGroupAC',
  66.                     'VertGroupA',
  67.                       'Space',
  68.                       'BeginLine',
  69.                         Text3(' Shared Songs     '),
  70.                         'Space',
  71.                         ClippedTextBoxMW(Right(Copies(' ',12)||NumSongs,12),1,12),
  72.                         'Space',
  73.                       'EndLine',
  74.                       'Space',
  75.                       'BeginLine',
  76.                         Text3(' Shared Bytes     '),
  77.                         'Space',
  78.                         ClippedTextBoxMW(Right(Copies(' ',12)||SBytes||' '||SFlag,12),2,12),
  79.                         'Space',
  80.                       'EndLine',
  81.                       'Space',
  82.                       'BeginLine',
  83.                         Text3(' Uploaded Songs   '),
  84.                         'Space',
  85.                         ClippedTextBoxMW(Right(Copies(' ',12)||NumReq,12),3,12),
  86.                         'Space',
  87.                       'EndLine',
  88.                       'Space',
  89.                       'BeginLine',
  90.                         Text3(' Uploaded Bytes   '),
  91.                         'Space',
  92.                         ClippedTextBoxMW(Right(Copies(' ',12)||UBytes||' '||UFlag,12),4,12),
  93.                         'Space',
  94.                       'EndLine',
  95.                       'Space',
  96.                       'BeginLine',
  97.                         Text3(' Library Playtime '),
  98.                         'Space',
  99.                         ClippedTextBoxMW(Right(Copies(' ',12)||Playtime,12),5,12),
  100.                         'Space',
  101.                       'EndLine',
  102.                       'Space',
  103.                     'EndGroup',
  104.                     'Space',
  105.                     'VertSeparator',
  106.                     'Space',
  107.                     'VertGroupAC',
  108.                       NamedSeparator('Top Requested Songs'),
  109.                       ListRO('TopSongs',6,0),
  110.                     'EndGroup',
  111.                   'EndGroup',
  112.                 'EndProject'
  113.  
  114. app = TR_CREATEAPP('TRCA_Name AmsterReport')
  115. If app ~= '00000000'x Then Do
  116.   window = TR_OPENPROJECT(app,windowtags)
  117.   If window ~= '00000000'x Then Do
  118.     Call ScanFile
  119.     Done = 0
  120.     Do While Done ~= 1
  121.       Call TR_WAIT(app,'')
  122.       Do While TR_HANDLEMSG(app,'event')
  123.         If event.trm_class = 'TRMS_ACTION' Then Do
  124.           Select
  125.             When event.trm_id = 7 Then Do
  126.               ShareList = ""
  127.               Call ScanFile
  128.             End
  129.             When event.trm_id = 8 Then Do
  130.               Call rtezrequest("AmsterReport.rexx v0.3"||D2C(10)||"By: Roger Clark (kaedric@texas.net)"||D2C(10)||"Date: September 8, 2000","Thanks","About AmsterReport.rexx")
  131.             End
  132.             When event.trm_id = 9 Then Do
  133.               Done = 1
  134.             End
  135.             Otherwise NOP
  136.           End
  137.         End
  138.         If event.trm_class = 'TRMS_CLOSEWINDOW' Then Do
  139.           Done = 1
  140.         End
  141.       End
  142.     End
  143.     Call TR_CLOSEPROJECT(window)
  144.   End
  145.   Call TR_DELETEAPP(app)
  146. End
  147. Exit
  148.  
  149. ScanFile:
  150.   NumSongs = 0
  151.   NumBytes = 0
  152.   NumBytesSent = 0
  153.   SBytes = 0
  154.   UBytes = 0
  155.   NumReq = 0
  156.   NumSecs = 0
  157.   TopSongs. = ""
  158.   TopSongs.0 = 0
  159.   TopReq = 0
  160.   SFlag = "KB"
  161.   UFlag = "KB"
  162.   Playtime = "0:00:00"
  163.  
  164.   If ShareList = "" then Do
  165.     If Dir = "" then Dir = Pragma("D")
  166.     ShareList = rtfilerequest(Dir,DefaultFile,"Choose Share File",,,)
  167.     If ShareList = "" then Return
  168.   End
  169.   If LastPos('/',ShareList) > LastPos(':',ShareList) then Do
  170.     DefaultFile = SubStr(ShareList,LastPos('/',ShareList)+1)
  171.     Dir = Left(ShareList,LastPos('/',ShareList))
  172.   End
  173.   Else Do
  174.     DefaultFile = SubStr(ShareList,LastPos(':',ShareList)+1)
  175.     Dir = Left(ShareList,LastPos(':',ShareList))
  176.   End
  177.   If Exists(ShareList) then Do
  178.     Call TR_SETATTRIBUTE(window,6,'TROB_Listview',TopSongs)
  179.     Call Open(In,ShareList,'R')
  180.       Do Until EOF(In)
  181.         SongName = ""
  182.         MD5 = ""
  183.         Size = 0
  184.         Bitrate = ""
  185.         Frequency = ""
  186.         Play = 0
  187.         ReqCountFlag = ""
  188.         Requests = 0
  189.         Data = ReadLn(In)
  190.         If Length(Data) < 1 then Leave
  191.         Parse Var Data '"'SongName'"' MD5 Size Bitrate Frequency Play ReqCountFlag Requests
  192.         If Requests = "" then Requests = 0
  193.         NumSongs = NumSongs + 1
  194.         NumReq = NumReq + Requests
  195.         If Requests = TopReq then Do
  196.           TopSongs.0 = TopSongs.0 + 1
  197.           Y = TopSongs.0
  198.           TopSongs.Y = SongName
  199.         End
  200.         If Requests > TopReq then Do
  201.           TopReq = Requests
  202.           TopSongs. = ""
  203.           TopSongs.0 = 1
  204.           TopSongs.1 = SongName
  205.         End
  206.         If Requests > 0 then Do
  207.           NumBytesSent = NumBytesSent + (Size * Requests)
  208.           If NumBytesSent > (1024 * 1024 * 1024) Then Do
  209.             UFlag = "GB"
  210.             UBytes = NumBytesSent / 1024 / 1024 / 1024 * 100 % 1 / 100
  211.           End
  212.           Else If NumBytesSent > (1024 * 1024) Then Do
  213.             UFlag = "MB"
  214.             UBytes = NumBytesSent / 1024 / 1024 * 100 % 1 / 100
  215.           End
  216.           Else Do
  217.             UFlag = "KB"
  218.             UBytes = NumBytesSent / 1024 * 100 % 1 / 100
  219.           End
  220.         End
  221.         NumBytes = NumBytes + Size
  222.         If NumBytes > (1024 * 1024 * 1024) Then Do
  223.           SFlag = "GB"
  224.           SBytes = NumBytes / 1024 / 1024 / 1024 * 100 % 1 / 100
  225.         End
  226.         Else If NumBytes > (1024 * 1024) Then Do
  227.           SFlag = "MB"
  228.           SBytes = NumBytes / 1024 / 1024 * 100 % 1 / 100
  229.         End
  230.         Else Do
  231.           SFlag = "KB"
  232.           SBytes = NumBytes / 1024 * 100 % 1 / 100
  233.         End
  234.         NumSecs = NumSecs + Play
  235.         Hours = NumSecs % 3600
  236.         Minutes = (NumSecs % 60) - (Hours * 60)
  237.         Seconds = NumSecs - (Hours * 3600) - (Minutes * 60)
  238.         Playtime = Hours":"Right("00"||Minutes,2)":"Right("00"||Seconds,2)
  239.         Call TR_SETATTRIBUTE(window,1,'TRAT_TEXT',Right(Copies(' ',12)||NumSongs,12))
  240.         Call TR_SETATTRIBUTE(window,2,'TRAT_TEXT',Right(Copies(' ',12)||SBytes||' '||SFlag,12))
  241.         Call TR_SETATTRIBUTE(window,3,'TRAT_TEXT',Right(Copies(' ',12)||NumReq,12))
  242.         Call TR_SETATTRIBUTE(window,4,'TRAT_TEXT',Right(Copies(' ',12)||UBytes||' '||UFlag,12))
  243.         Call TR_SETATTRIBUTE(window,5,'TRAT_TEXT',Right(Copies(' ',12)||Playtime,12))
  244.       End
  245.       If TopReq > 0 Then Do
  246.         Call TR_SETATTRIBUTE(window,6,'TROB_Listview',TopSongs)
  247.       End
  248.     Call Close(In)
  249.   End
  250.   Return
  251.  
  252. break_c:
  253. failure:
  254. halt:
  255. ioerr:
  256. syntax:
  257.    Call rtezrequest('Notify the author about this!'||D2C(10)||'+++ Error' rc 'in line' sigl '-' ERRORTEXT(rc),'Oops!','Error!')
  258.    If app ~= '00000000'x THEN
  259.       Call TR_DELETEAPP(app)
  260.    Exit
  261.